﻿<%@ Page Language="C#" MasterPageFile="~/Template.master" AutoEventWireup="true" CodeFile="KetQuaTimKiemSanPham.aspx.cs" Inherits="KetQuaTimKiemSanPham" Title="Untitled Page" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
<link href="jquery-ui/themes/base/ui.all.css" rel="stylesheet" type="text/css" />
<script src="jquery-ui/ui/ui.core.js" type="text/javascript"></script>
<script src="jquery-ui/pager/jquery.pager.js" type="text/javascript"></script>
<link href="jquery-ui/pager/Pager.css" rel="stylesheet" type="text/css" />
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<script language="javascript">
    var numOfPages;
    var keyword;
    var currentPage; 
    function selectPage(pageNum)
    {
        var url = "KetQuaTimKiemSanPham.aspx?keyword=" + keyword + "&currentPage=" + pageNum ;
        window.location = url;
    }
    $("#document").ready( function ()
    { 
       numOfPages = $("#ctl00_ContentPlaceHolder1_txtTotalPage").attr("value");
       //alert(numOfPages);
       keyword = $("#ctl00_ContentPlaceHolder1_txtKeyword").attr("value");
       currentPage = $("#ctl00_ContentPlaceHolder1_txtCurrentPage").attr("value");
       if (numOfPages>1)
    		{
   				
				$("#pager").pager({ pagenumber: currentPage,
    								pagecount: numOfPages,
    								buttonClickCallback:
    								function (pageclickednumber)
    								{
    									
										selectPage(pageclickednumber);
    								}
    						  	  });
    		}
    		else 
    		{
    		    if ( numOfPages == 1)
    			    $("#pager").html("");
    			if ( numOfPages == 0)
    			    $("#pager").html("Không tìm thấy sản phẩm phù hợp. Bấm <a href='Search.aspx'>vào đây</a> để tìm kiếm chính xác hơn . ");
    		}
       
    });
</script>
<br />
    <asp:HiddenField ID="txtTotalPage" runat="server" />
    <asp:HiddenField ID="txtKeyword" runat="server" />
    <asp:HiddenField ID="txtCurrentPage" runat="server" />
    <br />
    
    <asp:DataList ID="DataSanPhamTimKiem" runat="server" CellPadding="10" 
        RepeatColumns="5">
        
                <ItemTemplate>
                    <table class="style6">
                        <tr>
                            <td align="center">
                                <asp:Label ID="TenSanPham" runat="server" Text='<%# Eval("TenSanPham") %>' 
                                    Font-Bold="True"></asp:Label>
                                <asp:HiddenField ID="Hidden" runat="server" value='<%# Eval("ID") %>' />
                            <% 
                                DataSanPhamTimKiem.EditItemIndex += 1;
                                HiddenField idsanpham = (HiddenField)DataSanPhamTimKiem.Items[DataSanPhamTimKiem.EditItemIndex].Controls[1];

                                int id = int.Parse(idsanpham.Value);
                                DTO.SanPhamDto sanpham = BUS.SanPhamBus.LaySanPhamTheoID(id);
                                int songay = (DateTime.Today - sanpham.NgayNhap).Days;
                                if (songay < 30)
                                {           
                            %>
                                    <img alt="" src='images/new.gif' width='15px' height='15px' />
                            <%  } %>
                            </td>
                        </tr>
                        <tr>
                            <td align="center">
                                <asp:HyperLink ID="HyperLink1" runat="server" 
                                    NavigateUrl='<%# "Details.aspx?itemID=" + Eval("ID") %>'><img border="0px" src='<%# Eval("Hinh") %>' width='112px' height='101px' /></asp:HyperLink>
                            </td>
                        </tr>
                        <tr>
                            <td align="left" class="login_text" >
                                <asp:Label ID="Label3" runat="server" Text='<%# Eval("DonGia") + ".000 VND"%>' 
                                    Font-Size="8pt" ForeColor="White"></asp:Label>
                      
                                <asp:HyperLink ID="Gio" runat="server" ImageUrl="~/images/index_56.gif" 
                                    NavigateUrl='<%# "Cart.aspx?itemID=" + Eval("ID") %>' 
                                    Height="18px"></asp:HyperLink>
                            </td>
                        </tr>
                        
                    </table>
                </ItemTemplate>
            </asp:DataList>
    
<div id="pager"></div>
</asp:Content>

